﻿/*******************************************************************************
 * AAEngine
 * Copyright (c) 2010 Mike Jarosch
 *
 * Original source PushButton Engine:
 * Copyright (C) 2009 PushButton Labs, LLC
 * For more information see http://www.pushbuttonengine.com
 *
 * This file is licensed under the terms of the MIT license, which is included
 * in the "MIT License.txt" file at the root directory of this SDK.
 ******************************************************************************/

using AAEngine.Engine.Core;
using AAEngine.Engine.Entities;

namespace AAEngine.Components.Basic
{
    /// <summary>
    /// Event fired by the HealthComponent on the entity when health changes.
    /// </summary>
    public class HealthEvent : Event
    {
        public static readonly string DIED_EVENT = "AAEngine.Components.Basic.HealthEvent.DIED_EVENT";
        public static readonly string RESURRECTED_EVENT = "AAEngine.Components.Basic.HealthEvent.RESURRECTED_EVENT";
        public static readonly string DAMAGED_EVENT = "AAEngine.Components.Basic.HealthEvent.DAMAGED_EVENT";
        public static readonly string HEALED_EVENT = "AAEngine.Components.Basic.HealthEvent.HEALED_EVENT";

        /// <summary>
        /// Change in health.
        /// </summary>
        public float Delta { get; protected set; }

        /// <summary>
        /// Current health amount, after the delta. The health property on the 
        /// component is not updated until after the event is processed.
        /// </summary>
        public float Amount { get; protected set; }

        /// <summary>
        /// Entity which caused this damage (or healing), if any.
        /// </summary>
        public IEntity OriginatingEntity { get; protected set; }

        public HealthEvent(string type, float delta, float amount, IEntity originator)
            : base(type)
        {
            Delta = delta;
            Amount = amount;
            OriginatingEntity = originator;
        }

        public bool IsDead
        {
            get { return Amount == 0; }
        }
    }
}
